//Mark O'Meara
//CS2011
//Assignment: Sliding Window
//Due: 23/11/09

import tcdIO.Terminal;
	class SlidingWindowApp {
		
		public static void main(String args[]){
			
			SlidingWindow<Object> window;
			Terminal terminal1;
			terminal1 = new Terminal("App");
			Person person;//test person
			Person person2;//test person2
			
			
			window = new SlidingWindow<Object>(terminal1.readInt("Enter size of window: "));
			
			//Test Integers
			Integer test1 = terminal1.readInt("Enter integer: ");
			Integer test2 = terminal1.readInt("Enter integer2: ");
			window.push(test1);
			window.push(test2);

			terminal1.println("Checking if integer already existed... ");
			
			if(window.checkObject(test2))
				terminal1.println("Already Existed");
			else
				terminal1.println("Didn't already exist");
			
			terminal1.println("All current elements: ");
			terminal1.println(window.allElements());
			terminal1.println("Resetting . . .");
			//Reset
			window.reset();
			terminal1.println("All current elements: ");
			terminal1.println(window.allElements());
			
			//Testing strings
			String string1 = "Test";
			String string2 = "hi";
			
			window.push(string1);
			window.push(string2);
			
			terminal1.println("Checking if String 'hi' already existed... ");
			if(window.checkObject(string1) || window.checkObject(string2))
				terminal1.println("Already Existed");
			else
				terminal1.println("Didn't already exist");
			
			window.push(string2);
			
			terminal1.println("Checking if String 'test' already existed... ");
			if(window.checkObject(string2))
				terminal1.println("Already Existed");
			else
				terminal1.println("Didn't already exist");
			
			//Test person
			person = new Person("Mark", 19, "Student", 190);
			person2 = new Person("Joe", 20, "Student", 190);
			window.push(person);
			window.push(person2);
			window.push(person2);
			
			if(window.checkObject(person2)){
				terminal1.println("Person 2 already exists");
			}
			else{
				terminal1.println("Person 2 does not already exist");
			}
			
		}
}
